package com.sunrise.xdoc.entity.contact;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;

@Entity
@Table(name = "contact_khach_hang")
@Inheritance(strategy = InheritanceType.JOINED)
public class KhachHang extends AbstractContact {
	private static final long serialVersionUID = 4450816009226344311L;
	private String cmnd;
	private LoaiKhachHang loai;
	private String barcode; // ma khach hang luu trong the thanh vien

	@Column(name = "cmnd", unique = true)
	@Length(max = 20)
	public String getCmnd() {
		return cmnd;
	}

	public void setCmnd(String cmnd) {
		this.cmnd = cmnd;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "loai_khach_hang_id")
	public LoaiKhachHang getLoai() {
		return loai;
	}

	public void setLoai(LoaiKhachHang loai) {
		this.loai = loai;
	}

	@Column(name = "barcode", unique = true)
	@Length(max = 20)
	public String getBarcode() {
		return barcode;
	}

	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}

}
